home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 127 / PC Guia 127.iso / Software / Produtividade / OpenOffice.org 2.0.1 / openofficeorg2.cab / ooo2wordml_list.xsl < prev    next >
Extensible Markup Language  |  2005-09-10  |  20KB  |  349 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  
  4.     OpenOffice.org - a multi-platform office productivity suite
  5.  
  6.     $RCSfile: ooo2wordml_list.xsl,v $
  7.  
  8.     $Revision: 1.8 $
  9.  
  10.     last change: $Author: rt $ $Date: 2005/09/08 22:06:29 $
  11.  
  12.     The Contents of this file are made available subject to
  13.     the terms of GNU Lesser General Public License Version 2.1.
  14.  
  15.  
  16.       GNU Lesser General Public License Version 2.1
  17.       =============================================
  18.       Copyright 2005 by Sun Microsystems, Inc.
  19.       901 San Antonio Road, Palo Alto, CA 94303, USA
  20.  
  21.       This library is free software; you can redistribute it and/or
  22.       modify it under the terms of the GNU Lesser General Public
  23.       License version 2.1, as published by the Free Software Foundation.
  24.  
  25.       This library is distributed in the hope that it will be useful,
  26.       but WITHOUT ANY WARRANTY; without even the implied warranty of
  27.       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  28.       Lesser General Public License for more details.
  29.  
  30.       You should have received a copy of the GNU Lesser General Public
  31.       License along with this library; if not, write to the Free Software
  32.       Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  33.       MA  02111-1307  USA
  34.  
  35. -->
  36. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" exclude-result-prefixes="office table style text draw svg   dc config xlink meta oooc dom ooo chart math dr3d form script ooow draw">
  37.     <xsl:template name="ListStyles">
  38.         <w:lists>
  39.             <xsl:if test="descendant::text:list-level-style-image">
  40.                 <xsl:call-template name="PicLists"/>
  41.             </xsl:if>
  42.             <xsl:apply-templates select="office:styles/text:outline-style | office:styles/text:list-style | office:automatic-styles/text:list-style" mode="style"/>
  43.             <xsl:for-each select="office:styles/text:outline-style | office:styles/text:list-style | office:automatic-styles/text:list-style">
  44.                 <w:list w:ilfo="{position()}">
  45.                     <w:ilst w:val="{position()-1}"/>
  46.                 </w:list>
  47.             </xsl:for-each>
  48.         </w:lists>
  49.     </xsl:template>
  50.     <xsl:template match="text:list-style | text:outline-style" mode="style">
  51.         <w:listDef w:listDefId="{position()-1}">
  52.             <xsl:if test="name(..)='office:styles' and name()!='text:outline-style'">
  53.                 <w:styleLink w:val="{@style:name}"/>
  54.             </xsl:if>
  55.             <xsl:for-each select="text:list-level-style-number | text:list-level-style-bullet | text:list-level-style-image | text:outline-level-style">
  56.                 <xsl:if test="@text:level < 10">
  57.                     <w:lvl w:ilvl="{ @text:level - 1 }">
  58.                         <xsl:if test="name()='text:outline-level-style'">
  59.                             <xsl:variable name="headinglevel">
  60.                                 <xsl:value-of select="@text:level"/>
  61.                             </xsl:variable>
  62.                             <xsl:if test="/office:document/office:body//text:h[@text:level=$headinglevel and @text:style-name]">
  63.                                 <xsl:element name="w:pStyle">
  64.                                     <xsl:attribute name="w:val"><xsl:value-of select="/office:document/office:body//text:h[@text:level=$headinglevel]/@text:style-name"/></xsl:attribute>
  65.                                 </xsl:element>
  66.                             </xsl:if>
  67.                         </xsl:if>
  68.                         <xsl:choose>
  69.                             <xsl:when test="@text:start-value">
  70.                                 <w:start w:val="{@text:start-value}"/>
  71.                             </xsl:when>
  72.                             <xsl:otherwise>
  73.                                 <w:start w:val="1"/>
  74.                             </xsl:otherwise>
  75.                         </xsl:choose>
  76.                         <xsl:choose>
  77.                             <xsl:when test="@text:bullet-char">
  78.                                 <w:nfc w:val="23"/>
  79.                             </xsl:when>
  80.                             <xsl:when test="@style:num-format">
  81.                                 <xsl:call-template name="convert_list_number">
  82.                                     <xsl:with-param name="number-format" select="@style:num-format"/>
  83.                                 </xsl:call-template>
  84.                             </xsl:when>
  85.                         </xsl:choose>
  86.                         <xsl:choose>
  87.                             <xsl:when test="name()='text:list-level-style-image'">
  88.                                 <w:lvlText w:val="."/>
  89.                                 <w:lvlPicBulletId>
  90.                                     <xsl:attribute name="w:val"><xsl:value-of select="count(preceding::text:list-level-style-image)"/></xsl:attribute>
  91.                                 </w:lvlPicBulletId>
  92.                             </xsl:when>
  93.                             <xsl:when test="@text:bullet-char">
  94.                                 <w:lvlText w:val="{@text:bullet-char}"/>
  95.                             </xsl:when>
  96.                             <xsl:when test="@text:display-levels and not(../@text:consecutive-numbering='true')">
  97.                                 <xsl:variable name="levelText">
  98.                                     <xsl:call-template name="displaylevel">
  99.                                         <xsl:with-param name="number" select="@text:display-levels"/>
  100.                                         <xsl:with-param name="textlevel" select="@text:level"/>
  101.                                     </xsl:call-template>
  102.                                 </xsl:variable>
  103.                                 <w:lvlText w:val="{concat(@style:num-prefix, substring-after($levelText, '.'), @style:num-suffix)}"/>
  104.                             </xsl:when>
  105.                             <xsl:otherwise>
  106.                                 <w:lvlText w:val="{concat(@style:num-prefix, '%', @text:level, @style:num-suffix)}"/>
  107.                             </xsl:otherwise>
  108.                         </xsl:choose>
  109.                         <xsl:choose>
  110.                             <xsl:when test="style:list-level-properties/@fo:text-align = 'end'">
  111.                                 <w:lvlJc w:val="right"/>
  112.                             </xsl:when>
  113.                             <xsl:when test="style:list-level-properties/@fo:text-align = 'center'">
  114.                                 <w:lvlJc w:val="center"/>
  115.                             </xsl:when>
  116.                             <xsl:otherwise>
  117.                                 <w:lvlJc w:val="left"/>
  118.                             </xsl:otherwise>
  119.                         </xsl:choose>
  120.                         <xsl:choose>
  121.                             <xsl:when test="style:list-level-properties/@text:space-before | style:list-level-properties/@text:min-label-width | style:list-level-properties/@text:min-label-distance">
  122.                                 <xsl:call-template name="list_position"/>
  123.                             </xsl:when>
  124.                             <xsl:otherwise>
  125.                                 <w:suff w:val="Nothing"/>
  126.                             </xsl:otherwise>
  127.                         </xsl:choose>
  128.                         <xsl:apply-templates select="key('text-style',@text:style-name)/style:text-properties" mode="character"/>
  129.                         <xsl:apply-templates select="style:text-properties" mode="character"/>
  130.                     </w:lvl>
  131.                 </xsl:if>
  132.             </xsl:for-each>
  133.         </w:listDef>
  134.     </xsl:template>
  135.     <xsl:template match="text:list-style" mode="count">
  136.         <xsl:value-of select="count(preceding::text:list-style | preceding::text:outline-style)+1"/>
  137.     </xsl:template>
  138.     <xsl:template match="text:unordered-list | text:ordered-list | text:list">
  139.         <xsl:apply-templates select="text:unordered-list | text:ordered-list | text:list-item | text:list-header | text:list"/>
  140.     </xsl:template>
  141.     <xsl:template match="text:list-item | text:list-header">
  142.         <xsl:apply-templates select="text:unordered-list | text:ordered-list | text:list |  text:p |  text:h"/>
  143.     </xsl:template>
  144.     <xsl:template name="displaylevel">
  145.         <xsl:param name="number"/>
  146.         <xsl:param name="textlevel"/>
  147.         <xsl:if test="$number > 1">
  148.             <xsl:call-template name="displaylevel">
  149.                 <xsl:with-param name="number" select="$number -1"/>
  150.                 <xsl:with-param name="textlevel" select="number($textlevel)-1"/>
  151.             </xsl:call-template>
  152.         </xsl:if>
  153.         <xsl:value-of select="concat('.','%',$textlevel)"/>
  154.     </xsl:template>
  155.     <xsl:template name="list_position">
  156.         <xsl:variable name="spacebefore">
  157.             <xsl:choose>
  158.                 <xsl:when test="style:list-level-properties/@text:space-before">
  159.                     <xsl:call-template name="convert2twip">
  160.                         <xsl:with-param name="value" select="style:list-level-properties/@text:space-before"/>
  161.                     </xsl:call-template>
  162.                 </xsl:when>
  163.                 <xsl:otherwise>0</xsl:otherwise>
  164.             </xsl:choose>
  165.         </xsl:variable>
  166.         <xsl:variable name="space2text">
  167.             <xsl:choose>
  168.                 <xsl:when test="style:list-level-properties/@text:min-label-width">
  169.                     <xsl:call-template name="convert2twip">
  170.                         <xsl:with-param name="value" select="style:list-level-properties/@text:min-label-width"/>
  171.                     </xsl:call-template>
  172.                 </xsl:when>
  173.                 <xsl:otherwise>0</xsl:otherwise>
  174.             </xsl:choose>
  175.         </xsl:variable>
  176.         <xsl:variable name="spacedistance">
  177.             <xsl:choose>
  178.                 <xsl:when test="style:list-level-properties/@text:min-label-distance">
  179.                     <xsl:call-template name="convert2twip">
  180.                         <xsl:with-param name="value" select="style:list-level-properties/@text:min-label-distance"/>
  181.                     </xsl:call-template>
  182.                 </xsl:when>
  183.                 <xsl:otherwise>0</xsl:otherwise>
  184.             </xsl:choose>
  185.         </xsl:variable>
  186.         <xsl:if test="$spacedistance='0' and $space2text='0'">
  187.             <w:suff w:val="Nothing"/>
  188.         </xsl:if>
  189.         <w:pPr>
  190.             <xsl:if test="$spacedistance!='0' or $space2text!='0'">
  191.                 <w:tabs>
  192.                     <w:tab>
  193.                         <xsl:attribute name="w:val">list</xsl:attribute>
  194.                         <xsl:attribute name="w:pos"><xsl:choose><xsl:when test="number($spacedistance) > number($space2text)"><xsl:value-of select="number($spacebefore)+number($spacedistance)+150"/></xsl:when><xsl:otherwise><xsl:value-of select="number($spacebefore)+number($space2text)+150"/></xsl:otherwise></xsl:choose></xsl:attribute>
  195.                         <!-- Since SO MinSpaceDistance is width after number or bullet, MS TabSpaceAfter include the number or bullet width. So +150 -->
  196.                     </w:tab>
  197.                 </w:tabs>
  198.             </xsl:if>
  199.             <w:ind w:left="{number($space2text)+number($spacebefore)}" w:hanging="{$space2text}"/>
  200.             <!-- w:pos(MS TabSpaceAfter) = text:space-before + MAX(text:min-label-distance,text:min-label-width) + ( Symbol width ); w:left(MS IndentAt)= text:space-before + text:min-label-width; w:hanging(MS IndentAt - MS AlignedAt)=text:min-label-width -->
  201.         </w:pPr>
  202.     </xsl:template>
  203.     <xsl:template name="PicLists">
  204.         <xsl:for-each select="descendant::text:list-level-style-image">
  205.             <w:listPicBullet w:listPicBulletId="{position()-1}">
  206.                 <w:pict>
  207.                     <v:shape>
  208.                         <xsl:variable name="Picwidth">
  209.                             <xsl:call-template name="convert2pt">
  210.                                 <xsl:with-param name="value" select="style:list-level-properties/@fo:width"/>
  211.                             </xsl:call-template>
  212.                         </xsl:variable>
  213.                         <xsl:variable name="Picheight">
  214.                             <xsl:call-template name="convert2pt">
  215.                                 <xsl:with-param name="value" select="style:list-level-properties/@fo:height"/>
  216.                             </xsl:call-template>
  217.                         </xsl:variable>
  218.                         <xsl:attribute name="style"><xsl:value-of select="concat('width:', number($Picwidth*1), 'pt;height:', number($Picheight*1), 'pt')"/></xsl:attribute>
  219.                         <xsl:attribute name="o:bullet">t</xsl:attribute>
  220.                         <v:stroke joinstyle="miter"/>
  221.                         <w:binData w:name="{concat('wordml://SOpicbullet', position(), '.gif')}">
  222.                             <xsl:value-of select="office:binary-data"/>
  223.                         </w:binData>
  224.                         <v:imagedata src="{concat('wordml://SOpicbullet', position(), '.gif')}" o:title="{concat('SOpicbullet', position())}"/>
  225.                     </v:shape>
  226.                 </w:pict>
  227.             </w:listPicBullet>
  228.         </xsl:for-each>
  229.     </xsl:template>
  230.     <xsl:template name="convert_list_number">
  231.         <xsl:param name="number-format"/>
  232.         <xsl:choose>
  233.             <xsl:when test="$number-format = 'a'">
  234.                 <!-- nfcLCLetter: Lowercase alpah -->
  235.                 <w:nfc w:val="4"/>
  236.             </xsl:when>
  237.             <xsl:when test="$number-format = 'A'">
  238.                 <!-- nfcUCLetter: Uppercase alpha -->
  239.                 <w:nfc w:val="3"/>
  240.             </xsl:when>
  241.             <xsl:when test="$number-format = 'i'">
  242.                 <!-- nfcLCRoman: Lowercase roman -->
  243.                 <w:nfc w:val="2"/>
  244.             </xsl:when>
  245.             <xsl:when test="$number-format = 'I'">
  246.                 <!-- nfcUCRoman: Uppercase roman -->
  247.                 <w:nfc w:val="1"/>
  248.             </xsl:when>
  249.             <xsl:when test="$number-format = '∩╝æ, ∩╝Æ, ∩╝ô, ...'">
  250.                 <!-- '∩╝æ, ∩╝Æ, ∩╝ô, ...' also seems: decimal-full-width2 -->
  251.                 <w:nfc w:val="14"/>
  252.             </xsl:when>
  253.             <xsl:when test="$number-format = 'Γæá, Γæí, Γæó, ...'">
  254.                 <w:nfc w:val="18"/>
  255.             </xsl:when>
  256.             <xsl:when test="$number-format = 'Σ╕Ç, Σ║î, Σ╕ë, ...'">
  257.                 <!-- 'Σ╕Ç, Σ║î, Σ╕ë, ...' also seems: ideograph-digital, japanese-counting, japanese-digital-ten-thousand,
  258.                 taiwanese-counting, taiwanese-counting-thousand, taiwanese-digital, chinese-counting, korean-digital2 -->
  259.                 <w:nfc w:val="10"/>
  260.             </xsl:when>
  261.             <xsl:when test="$number-format = 'σú╣, Φ┤░, σÅü, ...'">
  262.                 <w:nfc w:val="38"/>
  263.             </xsl:when>
  264.             <xsl:when test="$number-format = 'σú╣, Φ▓│, σÅâ, ...'">
  265.                 <w:nfc w:val="34"/>
  266.             </xsl:when>
  267.             <xsl:when test="$number-format = 'τö▓, Σ╣Ö, Σ╕Ö, ...'">
  268.                 <w:nfc w:val="30"/>
  269.             </xsl:when>
  270.             <xsl:when test="$number-format = 'σ¡É, Σ╕æ, σ»à, ...'">
  271.                 <w:nfc w:val="31"/>
  272.             </xsl:when>
  273.             <xsl:when test="$number-format = 'σú▒, σ╝É, σÅé, ...'">
  274.                 <w:nfc w:val="16"/>
  275.             </xsl:when>
  276.             <xsl:when test="$number-format = 'πéó, πéñ, πéª, ...'">
  277.                 <w:nfc w:val="12"/>
  278.             </xsl:when>
  279.             <xsl:when test="$number-format = '∩╜▒, ∩╜▓, ∩╜│, ...'">
  280.                 <w:nfc w:val="20"/>
  281.             </xsl:when>
  282.             <xsl:when test="$number-format = 'πéñ, πâ¡, πâÅ, ...'">
  283.                 <w:nfc w:val="13"/>
  284.             </xsl:when>
  285.             <xsl:when test="$number-format = '∩╜▓, ∩╛¢, ∩╛è, ...'">
  286.                 <w:nfc w:val="21"/>
  287.             </xsl:when>
  288.             <xsl:when test="$number-format = '∞¥╝, ∞¥┤, ∞é╝, ...'">
  289.                 <!-- '∞¥╝, ∞¥┤, ∞é╝, ...' also seems: korean-counting -->
  290.                 <w:nfc w:val="41"/>
  291.             </xsl:when>
  292.             <xsl:when test="$number-format = 'πä▒, πä┤, πä╖, ...' or $number-format = 'πëá, πëí, πëó, ...'">
  293.                 <!-- mapping circled to uncirled -->
  294.                 <w:nfc w:val="25"/>
  295.             </xsl:when>
  296.             <xsl:when test='$number-format = "Ω░Ç, δéÿ, δïñ, ..." or $number-format = "πë«, πë», πë░, ..."'>
  297.                 <!-- mapping circled to uncirled -->
  298.                 <w:nfc w:val="24"/>
  299.             </xsl:when>
  300.             <xsl:when test="$number-format ='╪ú, ╪¿, ╪¬, ...'">
  301.                 <!-- 46.    hebrew-1-->
  302.                 <w:nfc w:val="46"/>
  303.             </xsl:when>
  304.             <xsl:when test="$number-format = 'α╕ü, α╕é, α╕â, ...'">
  305.                 <!--53.    thai-letters not match well !-->
  306.                 <w:nfc w:val="53"/>
  307.             </xsl:when>
  308.             <xsl:when test="$number-format='╫É, ╫æ, ╫Æ, ...'">
  309.                 <!--45.    arabic-alpha-->
  310.                 <w:nfc w:val="45"/>
  311.             </xsl:when>
  312.             <xsl:when test="string-length($number-format)=0">
  313.                 <w:nfc w:val="255"/>
  314.             </xsl:when>
  315.             <xsl:when test="$number-format = 'Native Numbering'">
  316.                 <xsl:variable name="locale" select="/office:document/office:meta/dc:language"/>
  317.                 <xsl:choose>
  318.                     <xsl:when test="starts-with($locale, 'th-')">
  319.                         <!-- for Thai, mapping thai-numbers, thai-counting to thai-numbers -->
  320.                         <w:nfc w:val="54"/>
  321.                     </xsl:when>
  322.                     <xsl:when test="starts-with($locale, 'hi-')">
  323.                         <!-- for Hindi, mapping hindi-vowels, hindi-consonants, hindi-counting to hindi-numbers -->
  324.                         <w:nfc w:val="51"/>
  325.                     </xsl:when>
  326.                     <xsl:when test="starts-with($locale, 'ar-')">
  327.                         <!-- for Arabic, mapping  arabic-abjad to arabic-alpha -->
  328.                         <w:nfc w:val="45"/>
  329.                     </xsl:when>
  330.                     <xsl:when test="starts-with($locale, 'he-')">
  331.                         <!-- for Hebrew, mapping hebrew-2 to  -->
  332.                         <w:nfc w:val="46"/>
  333.                     </xsl:when>
  334.                     <xsl:when test="starts-with($locale, 'ru-')">
  335.                         <!-- for Russian, mapping russian-upper to russian-lower -->
  336.                         <w:nfc w:val="58"/>
  337.                     </xsl:when>
  338.                     <xsl:when test="starts-with($locale, 'vi-')">
  339.                         <!-- for Vietnamese -->
  340.                         <w:nfc w:val="56"/>
  341.                     </xsl:when>
  342.                 </xsl:choose>
  343.             </xsl:when>
  344.             <!-- unsupported: ordinal, cardinal-text, ordinal-text, hex, chicago, bullet, ideograph-zodiac-traditional,
  345.             chinese-not-impl, korean-legal, none  -->
  346.         </xsl:choose>
  347.     </xsl:template>
  348. </xsl:stylesheet>
  349.